<template>
	<Layout :class="'bg-white p-2'">
		<Row class="p-1">
			<Col class="p-1" span="4">
				<Input class="w-100" v-model="searchKey.warehouseName" placeholder="请输入仓库名称" />
			</Col>
			<Col class="p-1" span="4">
				<Input class="w-100" v-model="searchKey.batchNo" placeholder="请输入入库批次" />
			</Col>
			<Col class="p-1" span="4">
				<Input class="w-100" v-model="searchKey.userName" placeholder="请输入管理员姓名" />
			</Col>
			<Col class="p-1" span="4">
				<Date-picker format="yyyy-MM-dd HH:mm:ss" type="datetime" @on-change="sdChange" placeholder="选择入库开始时间"></Date-picker>
			</Col>
			<Col class="p-1" span="4">
				<Date-picker format="yyyy-MM-dd HH:mm:ss" type="datetime" @on-change="edChange" placeholder="选择入库结束时间"></Date-picker>
			</Col>
			<Col class="p-1" span="4">
				<Input class="w-100" v-model="searchKey.pbatch" placeholder="请输入采购批次号" />
			</Col>
		</Row>
		
		<Row class="p-1">
			<Button class="m-1 float-right" type="primary" @click="search">查询</Button>
			<Button class="m-1 float-left" type="error"   @click="newInto">新增</Button>
		</Row>
		
		<Layout :class="'bg-white'">
			<Table border :class="'m-2'" :columns="tableInfo.columnInfo" :data="tableInfo.data">
				<template slot-scope="{ row, index }" slot="action">
					<Button size="small" style="margin-right: 5px" @click="switchPage(row.leaveId)">详细</Button>
				</template>
			</Table>
			<Page :class="'m-2 text-right'" :page-size="tableInfo.pageSize" @on-change="pageSearch"
				:total="tableInfo.total" />
		</Layout>
	</Layout>
</template>

<script>
	export default {
		data: function() {
			return {
				searchKey: {					
					warehouseId: "",	
					warehouseName: "",
					batchNo: "",
					userName: "",
					startDate: "",
					endDate: "",
					pbatch: "",
					current: 1,
					size: 10,
				},
				tableInfo: {
					currentPage: 1,
					total: 0,
					columnInfo: [{
							title: "入库批次号",
							align: 'center',
							key: "batchNo",
							width: 180
						},
						{
							title: "入库时间",
							align: 'center',
							key: "intoWarehouseDate",
							width: 180
						},
						{
							title: "仓库名称",
							align: 'center',
							key: "warehouseName",
							width: 180
						},
						{
							title: "采购订单批次号",
							align: 'center',
							key: "pbatch",
							width: 180
						},
						{
							title: "仓库管理员",
							align: 'center',
							key: "userName",
							width: 180
						},						
						{
							title: "操作",
							align: 'center',
							slot: 'action'
						}
					],
					data: []
				}
			};
		},
		created: function() {
			this.search();
		},
		methods: {
			search: function() {
				this.searchKey.current = 1;
				this.loadData();
			},
			sdChange: function(v) {
				this.searchKey.statuDate = v;
			},
			edChange: function(v) {
				this.searchKey.endDate = v;
			},
			loadData: function() {
				this.http.get({
					url: "/into/page",
					param: this.searchKey
				}).then(data => {
					this.tableInfo.currentPage = data.current;
					this.tableInfo.total = data.total;
					this.tableInfo.pageSize = data.size;
					this.tableInfo.data = data.records;
				});
			},
			pageSearch: function(changedPage) {
				this.searchKey.current = changedPage;
				this.loadData();
			},
			switchPage: function(leaveId) {
				this.$router.push({
					path: "/into/detail?leaveId=" + leaveId,
				});
			},
			newInto: function() {
				this.$router.push({
					path: "/into/new",
				});
			}
		}
	}
</script>

<style>
</style>
